package com.wyx.suanfa;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class MyStack {
    public static void main(String[] args) {

    }
}

/*
* class MyStack {
    Queue<Integer> queue;
    public MyStack() {
        queue = new LinkedList<>();//初始化
    }

    public void push(int x) {
        //offer方法，将x添加到队列尾部
        queue.offer(x);
        //每进来一个元素，就重新排列，把新进的元素放在最前边
        int size = queue.size();
        while(size-- > 1){
            //poll方法，将队列头元素出队并返回
            queue.offer(queue.poll());
        }

    }

    public int pop() {
        return queue.poll();
    }

    public int top() {
        return queue.peek();
    }

    public boolean empty() {
        return queue.isEmpty();
    }
}

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack obj = new MyStack();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.top();
 * boolean param_4 = obj.empty();
 */

